package com.bestcem.xm.user.service;

import com.alibaba.fastjson.JSONObject;
import com.bestcem.xm.common.core.domain.web.ServiceResult;
import com.bestcem.xm.user.service.dto.role.RolePermissionDTO;

import java.util.List;

/**
 * 用户权限
 *
 * @author Linked <zhijian.lin@idiaoyan.com>
 * @version v1.0
 * @date 2022/3/8 18:41
 */
public interface RolePermissionService {

    /**
     * 判断用户权限
     *
     * @param orgId  公司id
     * @param userId 用户id
     * @param method 方法
     * @param url    地址
     * @return java.lang.Boolean
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/08 19:02
     */
    Boolean hasPermission(String orgId, String userId, String method, String url);

    /**
     * 保存角色权限
     *
     * @param rolePermissionDTO
     * @return com.bestcem.xm.util.ServiceResult<java.lang.String>
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/17 17:45
     */
    ServiceResult<String> insertSelective(RolePermissionDTO rolePermissionDTO);

    /**
     * 更新角色权限
     *
     * @param rolePermissionDTO
     * @return com.bestcem.xm.util.ServiceResult<java.lang.Integer>
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/17 17:45
     */
    ServiceResult<Integer> updateByPrimaryKeySelective(RolePermissionDTO rolePermissionDTO);

    /**
     * 根据roleId删除角色权限
     *
     * @param roleId
     * @return com.bestcem.xm.util.ServiceResult<java.lang.Integer>
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/17 18:28
     */
    ServiceResult<Integer> deleteRolePermissionByRoleId(String roleId);

    /**
     * 根据orgId和roleId查询角色权限
     *
     * @param roleId
     * @return com.bestcem.xm.util.ServiceResult<java.lang.Integer>
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/17 18:28
     */
    ServiceResult<RolePermissionDTO> selectByOrgIdAndRoleId(String orgId, String roleId);

    /**
     * 通过角色id集合查询权限
     *
     * @param roleIds
     * @param orgId
     * @return ServiceResult<List < RolePermissionDTO>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/18 11:26
     */
    ServiceResult<List<RolePermissionDTO>> listByRoleIds(List<String> roleIds, String orgId);

    /**
     * 通过角色id集合批量更新权限
     *
     * @param roleIds
     * @param rolePermissionDTO
     * @return ServiceResult<Integer>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/21 11:27
     */
    ServiceResult<Integer> updateByIds(List<String> roleIds, RolePermissionDTO rolePermissionDTO);

    ServiceResult<Void> updateUserRolePermissions(String roleId, JSONObject permission);
}
